package com.example.demo04.until;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;

/**
 * @author taritari
 * @date 2023-10-22 18:11
 * @description
 */
public class RequestUtil {
    public static HttpResponse get(String url) {
        return HttpRequest.get(url).execute();
    }

    public static HttpResponse post(String url, String params) {
        return HttpRequest.post(url)
                .body(params)
                .execute();
    }

    public static HttpResponse postJson(String url, String json) {
        return HttpRequest.post(url)
                .contentType("application/json")
                .body(json)
                .header("Content-Type","application/json").header("Accept","")
                .execute();
    }

    public static HttpResponse setHeader(String url, String headerKey, String headerValue){
        return HttpRequest.get(url)
                .header(headerKey, headerValue)
                .execute();
    }
}
